import React, { Component } from 'react'

export default class componentName extends Component {
  state = {
    count: 8,
  }
  btnRef = React.createRef()
  render() {
    return (
      <div>
        <p>{this.state.count}</p>
        <button ref={this.btnRef}>+1</button>
      </div>
    )
  }
  async componentDidMount() {
    /* setTimeout(() => {
      this.setState({ count: 9 })
      // 生命周期里面进行 setState 的操作是异步的表现
      // !注意 18 版本这儿有变化
      console.log(this.state.count) // 9
    }) */

    /* this.btnRef.current.onclick = () => {
      this.setState({ count: this.state.count + 1 })
      console.log(this.state.count)
    } */
    await this.setState({ count: 99 })
    console.log(this.state.count)
  }
}
